{% if rewrite %}
RewriteEngine On
RewriteRule ^{{remotepath}}$ %{REQUEST_URI}/ [R=301]

{% endif %}
{% if header_scheme %}
RequestHeader set X-Forwarded-Scheme https early
RequestHeader set X-Scheme https early
RequestHeader set X-Forwarded-Proto https early

{% endif %}
{% if header_expect %}
RequestHeader unset Expect early

{% endif %}
{% if keephost %}
ProxyPreserveHost On
{% endif %}


{% if 'phx2' in inventory_hostname %}

{% if balancer_name is defined %}
<Proxy "balancer://{{balancer_name}}">
  {% for member in balancer_members %}
    BalancerMember "{{ member }}/{{remotepath}}"
  {% endfor %}
</Proxy>
ProxyPass {{ localpath }} "balancer://{{balancer_name}}"
{% else %}
ProxyPass {{ localpath }} {{ proxyurl }}{{remotepath}}
{% endif %}
ProxyPassReverse {{ localpath }} {{ proxyurl }}{{remotepath}}

{% else %}
Redirect 421 /
{% endif %}
